package com.easipass.business.controller.noauth;

import com.easipass.business.dto.page.MyNotesDTO;
import com.easipass.business.po.MyNotesPO;
import com.easipass.business.service.MyNoteService;
import com.easipass.commons.result.dto.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("myNote")
public class NotesController {

    @Autowired
    MyNoteService myNoteService;

    @GetMapping()
    public ApiResult getAllNotes(){
       List<MyNotesPO> res =  myNoteService.getAllNotes();
       return ApiResult.T(res);
    }

    @PutMapping()
    public ApiResult addNote(@RequestBody MyNotesDTO myNotesDTO){
        boolean res =  myNoteService.addNote(myNotesDTO);
        return ApiResult.T(res);
    }

    @PostMapping()
    public ApiResult updateNote(@RequestBody MyNotesDTO myNotesDTO){
        boolean res =  myNoteService.updateNote(myNotesDTO);
        return ApiResult.T(res);
    }

    @DeleteMapping()
    public ApiResult deleteNote(@RequestParam String noteId){
        boolean res =  myNoteService.deleteOneNote(noteId);
        return ApiResult.T(res);
    }
}
